package com.clound.order.message;

import com.clound.order.dto.OrderDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * Created by zzy on 2018/4/12.
 */
@Component
@EnableBinding(StreamClient.class)
public class StreamReceiver {

    private final static Logger log= LoggerFactory.getLogger(StreamReceiver.class);

/*    @StreamListener(StreamClient.INPUT)
    public void process(Object message){
        log.info("StreamReceiver:"+message.toString());
    }*/

    /**
     * 接收orderDto
     * @param message
     */
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.INPUT2)
    public String process(OrderDTO message){
        log.info("StreamReceiver:"+message.getOrderId());
        return "received";
    }

    @StreamListener(StreamClient.INPUT2)
    public void process2(String message){
        log.info("StreamReceiver:"+message);
    }
}
